package com.topnav.mc.gbserverapi;

import com.dtflys.forest.annotation.*;

/**
 * 访问远程服务器的API
 * 接口
 */
public interface GbServerApi {

    /** 设备查询 */

    //private final String URL_DEVICES_QUERY="http://{host}/api/device/query/devices?page={pageNum}&count={pageSize}";
    /**
     * 从国标服务器上查询所有设备
     * @param url
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Get(
            value = "{url}/api/device/query/devices?page={pageNum}&count={pageSize}",
            headers = {"Content-Type : application/x-www-form-urlencoded;charset=UTF-8",},
            contentType = "application/x-www-form-urlencoded"
    )
    String devices(
            @Var("url") String url,
            @Var("pageNum") String pageNum,
            @Var("pageSize") String pageSize);



    //private String URL_CHANNEL_SYNC="http://{host}/api/device/query/devices/{deviceId}/sync";
    /**
     * 设备通道同步
     * @param url
     * @param deviceId
     * @return
     */
    @Post(
            value = "{url}/api/device/query/devices/{deviceId}/sync",
            headers = {"Content-Type : application/x-www-form-urlencoded;charset=UTF-8",},
            contentType = "application/x-www-form-urlencoded"
    )
    String syncChannels(
            @Var("url") String url,
            @Var("deviceId") String deviceId);


    //private String URL_SYNC_STATUS="http://{host}/api/device/query/{deviceId}/sync_status/";
    /**
     * 设备通道同步状态查询
     * @param url
     * @param deviceId
     * @return
     */
    @Get(
            value = "{url}/api/device/query/{deviceId}/sync_status",
            headers = {"Content-Type : application/x-www-form-urlencoded;charset=UTF-8",},
            contentType = "application/x-www-form-urlencoded"
    )
    String syncStatus(
            @Var("url") String url,
            @Var("deviceId") String deviceId);


    //private String URL_CHANNEL_QUERY="http://{host}/api/device/query/devices/{deviceId}/channels?page={pageNum}&count={pageSize}";
    /**
     * 设备通道查询
     * @param url
     * @param deviceId
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Get(
            value = "{url}/api/device/query/devices/{deviceId}/channels?page={pageNum}&count={pageSize}",
            headers = {"Content-Type : application/x-www-form-urlencoded;charset=UTF-8",},
            contentType = "application/x-www-form-urlencoded"
    )
    String channels(
            @Var("url") String url,
            @Var("deviceId") String deviceId,
            @Var("pageNum") String pageNum,
            @Var("pageSize") String pageSize);

    /**
     * 登录
     * @param url
     * @param username
     * @param password
     * @return
     */
    @Get(
            value = "{url}/api/user/login?username={username}&password={password}",
            headers = {"Content-Type : application/x-www-form-urlencoded;charset=UTF-8",},
            contentType = "application/x-www-form-urlencoded"
    )
    String login(
            @Var("url") String url,
            @Var("username") String username,
            @Var("password") String password
    );

    /**
     * 检查服务器是否在线
     * @param url
     * @return
     */
    @Get(
            value = "{url}/api/subjoin/info",
            headers = {"Content-Type : application/x-www-form-urlencoded;charset=UTF-8",},
            contentType = "application/x-www-form-urlencoded"
    )
    String info(@Var("url") String url);


    /**
     * 取得播放地址
     * @param url
     * @param deviceCode
     * @param channelCode
     * @return
     */
    @Get(
            value = "{url}/api/play/start/{deviceCode}/{channelCode}",
            headers = {"Content-Type : application/x-www-form-urlencoded;charset=UTF-8",},
            contentType = "application/x-www-form-urlencoded"
    )
    String playStart(
            @Var("url") String url,
            @Var("deviceCode") String deviceCode,
            @Var("channelCode") String channelCode
    );


    /**
     * 取得国标服务器的参数，如playTimeout
     * @param url
     * @return
     */
    @Get(
            value = "{url}/api/subjoin/get/config",
            headers = {"Content-Type : application/x-www-form-urlencoded;charset=UTF-8",},
            contentType = "application/x-www-form-urlencoded"
    )
    String getConfig(
            @Var("url") String url
    );

    //http://106.52.41.35:18080/api/user/login?username=admin&password=21232f297a57a5a743894a0e4a801fc3
}
